import { axios } from "../utils/request";
import JSEncrypt from 'jsencrypt';

// import qs from "qs";

const api = {
    GetPublicKey: "/public/getPublicKey",
};
/**
 * 获取公钥
 * @returns {*}
 */
export function GetPublicKey() {
  return axios({
    url: api.GetPublicKey,
    method: "get",
  });
};

/**
 * 利用公钥加密
 * @param {公钥} publicKey 
 * @param {需要加密的字符串} encryptWord 
 */
export function Encrypt(publicKey,encryptWord){
    const encrypt = new JSEncrypt();
    encrypt.setPublicKey(publicKey);
    let encryptKey = encrypt.encrypt(encryptWord);// 加密后的字符串
    return encryptKey;
}

